package object.homework;

/**
 * replaceAll()：替换，将当前字符串中满足正则表达式的部分给替换为指定字符串
 * <p>
 * String replaceAll(String regex,String replacement)
 * 将当前字符串中满足正则表达式(regex)的部分替换为给定内容(replacement)
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        String a = "abc123cdf456";
        String b = a.replaceAll("[a-zA-Z]+", "AAA");
        System.out.println(b);

        String c = "你是sb,你有病，你是猪";
        String d = "(sb|病|猪)";
        String e = c.replaceAll(d, "***");
        System.out.println(e);
        /*
        String str = "abc123def456ghi";
        String rep = str.replaceAll("[0-9]+","哈哈哈");// //将数字部分替换为哈哈哈
        System.out.println(rep);

        String message = "你sb,gun吧!";
        String a = message.replaceAll("sb|gun","***");
        System.out.println(a);
         */
    }
}
